import { editor } from "monaco-editor";

export type VoidTypeFun<T> = (d: T) => void;
export type voidFun = () => void;

/** 可遍历对象 */
export type IKeyMap<T extends string | number | symbol, V> = {
  [key in T]: V;
};

// fileStateMap monaco 语言模型状态和model 映射
export type IEditorStateMap = Map<
  string,
  { state: editor.ICodeEditorViewState | null; model: editor.ITextModel | null }
>;

// 定义monaco event handle 回调参数类型
export type IEditorEvent = {
  keyCode: number;
  ctrlKey: boolean;
  shiftKey: boolean;
  altKey: boolean;
  browserEvent: { preventDefault: voidFun };
};

// 定义搜搜结果集
export type ISearchResultItem = {
  filename: string;
  filepath: string;
  result: editor.FindMatch[]; // 保存位置信息
  LineContents: string[];
};

// 定义搜索结果与 Monaco 交互的数据
export type ISearchToEditorResult = {
  filepath: string;
  result: editor.FindMatch; // 保存位置信息
};
